package com.bjtu.laorenyouhao.yigong.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjtu.common.utils.PageUtils;
import com.bjtu.common.utils.Query;

import com.bjtu.laorenyouhao.yigong.dao.YigongInfoDao;
import com.bjtu.laorenyouhao.yigong.entity.YigongInfoEntity;
import com.bjtu.laorenyouhao.yigong.service.YigongInfoService;
import org.springframework.util.StringUtils;


@Service("yigongInfoService")
public class YigongInfoServiceImpl extends ServiceImpl<YigongInfoDao, YigongInfoEntity> implements YigongInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String key = (String) params.get("key");
        QueryWrapper<YigongInfoEntity> queryWrapper = new QueryWrapper<YigongInfoEntity>();
        if (StringUtils.hasLength(key)){
            queryWrapper.eq("id",key)
                    .or().like("name",key);
        }

        IPage<YigongInfoEntity> page = this.page(
                new Query<YigongInfoEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}